import {
	defineConfig
} from 'vite';
import uni from '@dcloudio/vite-plugin-uni';


import {
	viteMockServe
} from 'vite-plugin-mock'

export default defineConfig({
	plugins: [
		uni(),
		viteMockServe({
			mockPath: "./mock"
		}),
	],
	build: {
		minify: 'terser',
		terserOptions: {
			compress: {
				drop_console: true,
			},
		},
	},
	server: {
		proxy: {
			/*
			接口调用时这么写：
			uni.request({
				url: "/api/user"
				data:{},
				success(res){
					
				}
			})
			*/
			// '/api': {
			// 	target: 'http://localhost:3000',
			// 	changeOrigin: true, //如果跨域需对此参数设置
			// 	// pathRewrite: {
			// 	// 	'^/api': ''
			// 	// },
			// 	rewrite: path => {
			// 		return path.replace(/^\/api/, '/')
			// 	}
			// }
			'/dpc': {
				target: 'http://localhost:3000',
				changeOrigin: true, //如果跨域需对此参数设置
				rewrite: path => {
					return path.replace(/^\/dpc/, '/')
				}
			}
		},
	}
});